﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MINERP.BLL.Statistics;

namespace MINERP.Statistics.Forms
{
    public partial class FrmSalemanAchievement : Form
    {
        SalemanAchievementBLL bll = new SalemanAchievementBLL();
        private static FrmSalemanAchievement instance = null;
        private FrmSalemanAchievement()
        {
            InitializeComponent();
        }

        public static FrmSalemanAchievement GetInstance
        {
            get 
            {
                if (instance == null)
                {
                    instance = new FrmSalemanAchievement();

                }
                return instance;
            }
        }
        private void simpleButtonOk_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            simpleButtonOk.Enabled = false;

            try
            {
                report1.Preview = previewControl1;
                report1.RegisterData(bll.GetSalemanAchievement(dateEditStartTime.DateTime, dateEditEndTime.DateTime));

                report1.Load(Application.StartupPath + "\\SalemanAchievement.frx");
                report1.SetParameterValue("startTime", dateEditStartTime.DateTime);
                report1.SetParameterValue("endTime", dateEditEndTime.DateTime);
                previewControl1.Refresh();
                previewControl1.Show();
                report1.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
            finally
            {
                simpleButtonOk.Enabled = true;
                this.Cursor = Cursors.Default;
            }
        }

        private void FrmSalemanAchievement_FormClosing(object sender, FormClosingEventArgs e)
        {
            instance = null;
        }

        private void FrmSalemanAchievement_Load(object sender, EventArgs e)
        {
            dateEditEndTime.DateTime = DateTime.Now;
            dateEditStartTime.DateTime = DateTime.Now;
        }
    }
}
